/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package com.stip.server.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author BlueBerry
 */
@Entity
@Table(name = "activeties")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Activeties.findAll", query = "SELECT a FROM Activeties a"),
    @NamedQuery(name = "Activeties.findById", query = "SELECT a FROM Activeties a WHERE a.id = :id"),
    @NamedQuery(name = "Activeties.findByFirstEnsure", query = "SELECT a FROM Activeties a WHERE a.firstEnsure = :firstEnsure"),
    @NamedQuery(name = "Activeties.findBySecondEnsure", query = "SELECT a FROM Activeties a WHERE a.secondEnsure = :secondEnsure"),
    @NamedQuery(name = "Activeties.findByThirdEnsure", query = "SELECT a FROM Activeties a WHERE a.thirdEnsure = :thirdEnsure"),
    @NamedQuery(name = "Activeties.findByValidity", query = "SELECT a FROM Activeties a WHERE a.validity = :validity"),
    @NamedQuery(name = "Activeties.findByAbstracts", query = "SELECT a FROM Activeties a WHERE a.abstracts = :abstracts"),
    @NamedQuery(name = "Activeties.findByActDate", query = "SELECT a FROM Activeties a WHERE a.actDate = :actDate"),
    @NamedQuery(name = "Activeties.findByStatus", query = "SELECT a FROM Activeties a WHERE a.status = :status"),
    @NamedQuery(name = "Activeties.findByUrl", query = "SELECT a FROM Activeties a WHERE a.url = :url"),
    @NamedQuery(name = "Activeties.findByEmail", query = "SELECT a FROM Activeties a WHERE a.email = :email")})
public class Activeties implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Column(name = "first_ensure")
    private Integer firstEnsure;
    @Column(name = "second_ensure")
    private Integer secondEnsure;
    @Column(name = "third_ensure")
    private Integer thirdEnsure;
    @Column(name = "validity")
    @Temporal(TemporalType.TIMESTAMP)
    private Date validity;
    @Size(max = 200)
    @Column(name = "abstracts")
    private String abstracts;
    @Column(name = "act_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date actDate;
    @Column(name = "status")
    private Integer status;
    @Size(max = 255)
    @Column(name = "url")
    private String url;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="电子邮件无效")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 50)
    @Column(name = "email")
    private String email;
    @OneToMany(mappedBy = "actId")
    private List<UserAct> userActList;
    @JoinColumn(name = "third-org", referencedColumnName = "id")
    @ManyToOne
    private Organization thirdOrg;
    @JoinColumn(name = "second-org", referencedColumnName = "id")
    @ManyToOne
    private Organization secondOrg;
    @JoinColumn(name = "first_org", referencedColumnName = "id")
    @ManyToOne
    private Organization firstOrg;
    @JoinColumn(name = "location", referencedColumnName = "id")
    @ManyToOne
    private Locations location;

    public Activeties() {
    }

    public Activeties(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getFirstEnsure() {
        return firstEnsure;
    }

    public void setFirstEnsure(Integer firstEnsure) {
        this.firstEnsure = firstEnsure;
    }

    public Integer getSecondEnsure() {
        return secondEnsure;
    }

    public void setSecondEnsure(Integer secondEnsure) {
        this.secondEnsure = secondEnsure;
    }

    public Integer getThirdEnsure() {
        return thirdEnsure;
    }

    public void setThirdEnsure(Integer thirdEnsure) {
        this.thirdEnsure = thirdEnsure;
    }

    public Date getValidity() {
        return validity;
    }

    public void setValidity(Date validity) {
        this.validity = validity;
    }

    public String getAbstracts() {
        return abstracts;
    }

    public void setAbstracts(String abstracts) {
        this.abstracts = abstracts;
    }

    public Date getActDate() {
        return actDate;
    }

    public void setActDate(Date actDate) {
        this.actDate = actDate;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @XmlTransient
    public List<UserAct> getUserActList() {
        return userActList;
    }

    public void setUserActList(List<UserAct> userActList) {
        this.userActList = userActList;
    }

    public Organization getThirdOrg() {
        return thirdOrg;
    }

    public void setThirdOrg(Organization thirdOrg) {
        this.thirdOrg = thirdOrg;
    }

    public Organization getSecondOrg() {
        return secondOrg;
    }

    public void setSecondOrg(Organization secondOrg) {
        this.secondOrg = secondOrg;
    }

    public Organization getFirstOrg() {
        return firstOrg;
    }

    public void setFirstOrg(Organization firstOrg) {
        this.firstOrg = firstOrg;
    }

    public Locations getLocation() {
        return location;
    }

    public void setLocation(Locations location) {
        this.location = location;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Activeties)) {
            return false;
        }
        Activeties other = (Activeties) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.stip.server.entities.Activeties[ id=" + id + " ]";
    }
    
}
